package bolangit.test.exception;


import bolangit.test.constant.ErrorConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author lxr
 * @date 2019/2/27
 * @email 200890949@qq.com
 * @decreption 异常
 */
public class AjaxException extends RuntimeException {
    private static final long serialVersionUID = -8798278124229763202L;
    private static Log log = LogFactory.getLog(AjaxException.class);

    private int errorCode = 0;

    public AjaxException(String errorString) {
        this(ErrorConstants.OTHER_ERROR, errorString);
    }

    public AjaxException(int errorCode, String errorString) {
        super(errorString);
        this.errorCode = errorCode;

        log.error("ServiceException: errorCode=" + errorCode + ", errorMessage=" + errorString, this);
    }

    public AjaxException(String errorString, Throwable cause) {
        this(ErrorConstants.OTHER_ERROR, errorString, cause);
    }
    public AjaxException(int errorCode, String errorString, Throwable cause) {
        super(errorString, cause);
        this.errorCode = errorCode;

        log.error("ServiceException: errorCode=" + errorCode + ", errorMessage=" + errorString, this);
    }

    public int getErrorCode() {
        return this.errorCode;
    }

    public String getErrorMessage() {
        return this.getMessage();
    }
}
